package wh;

import java.io.DataInput;
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;

public class PacketStreamReader
{
  private byte[] m_byteBuffer;
  DataInputStream m_iStream;

  public DataInput getDataInput()
  {
    return this.m_iStream;
  }

  public PacketStreamReader(InputStream paramInputStream)
  {
    this.m_iStream = new DataInputStream(paramInputStream);
  }

  public byte[] getBuffer()
  {
    return this.m_byteBuffer;
  }

  public short readPacket(byte[] paramArrayOfByte)
    throws IOException
  {
    short i = this.m_iStream.readShort();
    paramArrayOfByte[0] = (byte)(i >> 8);
    paramArrayOfByte[1] = (byte)(i & 0xFF);
    if ((i < 0) || (i > paramArrayOfByte.length))
      throw new IOException("Illegal numBytes read: " + i);
    this.m_iStream.readFully(paramArrayOfByte, 2, i);
    return i;
  }

  public short readPacket()
    throws IOException
  {
    if (this.m_byteBuffer == null)
      this.m_byteBuffer = new byte[4096];
    return readPacket(this.m_byteBuffer);
  }
}

/* Location:           /Users/MacOSX/Wormhole/
 * Qualified Name:     PacketStreamReader
 * JD-Core Version:    0.5.4
 */